import 'package:flutter/material.dart';
import 'package:jieqifang/global.dart';

class IntroPage extends StatefulWidget {
  IntroPage({Key key}) : super(key: key);

  @override
  _IntroPageState createState() => _IntroPageState();
}

class _IntroPageState extends State<IntroPage> {
  @override
  void initState() {
    super.initState();
  }

  List<Widget> renderExplain(explains) {
    List<Widget> list = [];
    for (var i = 0; i < explains.length; i++) {
      var explain = explains[i];
      list.add(Row(
        children: [
          Container(
            padding: EdgeInsets.fromLTRB(2, 0, 2, 2),
            color: explain['color'],
            child: Text(
              explain['name'],
              style: TextStyle(
                color: Global.backgroundColor,
                fontSize: 17,
                fontFamily: 'QiuHongKai',
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
          SizedBox(width: 7),
          Expanded(
            child: Text(
              explain['explain'],
              style: TextStyle(
                color: Global.fontColor,
                fontSize: 17,
                fontFamily: 'QiuHongKai',
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
        ],
      ));
      list.add(
        SizedBox(height: 10),
      );
    }
    return list;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          '二十四节气',
          style: TextStyle(
            color: Global.fontColor,
            fontSize: 19,
            fontFamily: 'QiuHongKai',
            fontWeight: FontWeight.bold,
          ),
        ),
        brightness: Brightness.light,
        backgroundColor: Global.backgroundColor,
        elevation: 0,
      ),
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        padding: EdgeInsets.all(10),
        color: Global.backgroundColor,
        child: SingleChildScrollView(
          child: Column(
            children: [
              Container(
                margin: EdgeInsets.only(left: 5),
                padding: EdgeInsets.only(left: 10),
                decoration: BoxDecoration(
                  border: Border(
                    left: BorderSide(
                      width: 4,
                      color: Global.fontColor.withOpacity(.1),
                    ),
                  ),
                ),
                child: Text(
                  '远在春秋时期，中国古代先贤就定出仲春、仲夏、仲秋和仲冬等四个节气，以后不断地改进和完善，到秦汉年间，二十四节气已完全确立，成为中国古代一种用来指导农事的补充历法。二十四节气指导着传统农业生产和日常生活，被誉为“中国的第五大发明”。',
                  style: TextStyle(
                    color: Global.fontSecondColor,
                    fontSize: 14,
                    // fontFamily: 'QiuHongKai',
                    fontWeight: FontWeight.w400,
                  ),
                ),
              ),
              Container(
                padding: EdgeInsets.all(10),
                child: Image.asset('assets/images/intro-1.jpg'),
              ),
              Text(
                '二十四节气歌',
                style: TextStyle(
                  color: Global.fontColor,
                  fontFamily: 'QiuHongKai',
                  fontSize: 19,
                  fontWeight: FontWeight.w600,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '春雨惊春清谷天，夏满芒夏暑相连。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '秋处露秋寒霜降，冬雪雪冬小大寒。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '每月两节不变更，最多相差一两天。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '上半年来六廿一，下半年是八廿三。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 40),
              Text(
                '二十四节气七言律诗',
                style: TextStyle(
                  color: Global.fontColor,
                  fontFamily: 'QiuHongKai',
                  fontSize: 19,
                  fontWeight: FontWeight.w600,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '西园梅放立春先，云镇霄光雨水连。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '惊蛰初交河跃鲤，春分蝴蝶梦花间。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '清明时放风筝好，谷雨西厢宜养蚕。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '牡丹立夏花零落，玉簪小满布庭前。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '隔溪芒种渔家乐，农田耕耘夏至间。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '小暑白罗衫着体，望河大暑对风眠。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '立秋向日葵花放，处暑西楼听晚蝉。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '翡翠园中沾白露，秋分折桂月华天。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '枯山寒露惊鸿雁，霜降芦花红蓼滩。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '立冬畅饮麒麟阁，绣褥小雪吟诗篇。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '幽阖大雪红炉暖，冬至琵琶懒去弹。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Text(
                '小寒高卧邯郸梦，捧雪飘空交大寒。',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 20),
              Container(
                padding: EdgeInsets.all(10),
                child: Image.asset('assets/images/intro-2.jpg'),
              ),
              SizedBox(height: 20),
              Text(
                '二十四节气的含义',
                style: TextStyle(
                  color: Global.fontColor,
                  fontSize: 17,
                  fontFamily: 'QiuHongKai',
                  fontWeight: FontWeight.w500,
                ),
              ),
              SizedBox(height: 10),
              Container(
                width: MediaQuery.of(context).size.width,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: renderExplain(Global.jieqiList),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
